import type { ActionContext } from "vuex";
import type { State, Counter } from "../../vuex";

// interface Context<S> extends ActionContext<S, State> {}
// Context<Counter>

export default {
  namespaced: true,
  state: {
    count: 0,
  },
  getters: {},
  actions: {
    increment({ commit }: ActionContext<Counter, State>, val: number) {
      commit("INCREMENT", val);
    },
    decrement({ commit }: ActionContext<Counter, State>, val: number) {
      commit("DECREMENT", val);
    },
  },
  mutations: {
    INCREMENT(state: Counter, val: number) {
      state.count += val;
    },
    DECREMENT(state: Counter, val: number) {
      state.count -= val;
    },
  },
};
